package com.javastudy.basis.properties;

import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import static org.junit.Assert.*;

public class PropertiesFeatures {

	@Test
	public void testLoadPropertiesFromFile() {
		Properties properties = null;
		InputStream is = null;
		if (is == null) {
			try {
				is = PropertiesFeatures.class.getResourceAsStream("/com/javaapi/properties/catalina.properties");//注意这里是怎么read file的
			} catch (Throwable t) {
				// handleThrowable(t);
			}
		}

		if (is != null) {
			try {
				properties = new Properties();
				properties.load(is);
			} catch (Throwable t) {
				t.printStackTrace();
				// handleThrowable(t);
				// log.warn(t);
			} finally {
				try {
					is.close();
				} catch (IOException ioe) {
					ioe.printStackTrace();
					// log.warn("Could not close catalina.properties", ioe);
				}
			}
		}
		System.out.println(properties);
	}

}
